#include "TalkWindowItem.h"
#include "ui_TalkWindowItem.h"
#include "CommonUtils.h"

TalkWindowItem::TalkWindowItem(QWidget *parent)
	: QWidget(parent)
{
	ui = new Ui::TalkWindowItem();
	ui->setupUi(this);

	initControl();
}

TalkWindowItem::~TalkWindowItem()
{
	delete ui;
}

void TalkWindowItem::setHeadPixmap(const QString & headPixmapPath)
{
	//QPixmap(":/Resources/MainWindow/head_mask.png"),
	QPixmap pixmap=
		CommonUtils::getRoundImage(
			QPixmap(headPixmapPath), 
			//QPixmap(":/Resources/MainWindow/xm.png"),
			QPixmap(":/Resources/MainWindow/head_mask.png"),
			ui->headlabel->size()
		);

	ui->headlabel->setPixmap(pixmap);
}

void TalkWindowItem::setMsgLabelContent(const QString & msg)
{
	ui->msgLabel->setText(msg);
}

QString TalkWindowItem::getMsgLabelText()
{
	return ui->msgLabel->text();
}

void TalkWindowItem::initControl()
{
	ui->tclosebtn->setVisible(false);
	connect(ui->tclosebtn, SIGNAL(clicked(bool)),
		this, SIGNAL(signalCloseClicked(bool)));
}

void TalkWindowItem::enterEvent(QEvent * event)
{
	ui->tclosebtn->setVisible(true);
}

void TalkWindowItem::leaveEvent(QEvent * event)
{
	ui->tclosebtn->setVisible(false);
}

void TalkWindowItem::resizeEvent(QResizeEvent * event)
{
	__super::resizeEvent(event);
}


